﻿#ifndef __ALGRSA_PR_H__
#define __ALGRSA_PR_H__

#include <mbedtls/rsa.h>



typedef struct 
{
	UINT32 bits;                // length in bits of modulus 
	UINT32 PublicExponent;      // public exponent 
}R_RSA_PROTO_KEY;

/* RSA public key. */	

typedef struct 
{
	UINT16 bits;				// length in bits of modulus
	UINT32* modulus;				// modules 
	UINT32* publicExponent;      // public exponent         
}R_RSA_PUBLIC_KEY;

/* RSA private key. */	
typedef struct 
{
	UINT16 bits;               // length in bits of modulus  	
	UINT32* modulus;            // modulus                	
	UINT32* publicExponent;     // public exponent        	
	UINT32* exponent;           // private exponent        
	UINT32* prime[2];           // prime factors          
	UINT32* primeExponent[2];   // exponents for CRT        
	UINT32* coefficient;        // CRT coefficient         
}R_RSA_PRIVATE_KEY,R_RSA_KEYPAIR;

	extern UINT8 ALGRsa_PR_GenKeyPair(R_RSA_PROTO_KEY protoKey,R_RSA_PRIVATE_KEY *pRSAKey);
	extern UINT8 ALGRsa_PR_PubKeyOpt(UINT8 *output,UINT32 *outputLen, UINT8 *input,UINT32 inputLen,R_RSA_PUBLIC_KEY *RSAKey);
	extern UINT8 ALGRsa_PR_PriKeyOpt(UINT8 *output,UINT32 *outputLen, UINT8 *input,UINT32 inputLen,R_RSA_PRIVATE_KEY *RSAKey);
	extern UINT8 ALGRsa_PR_PriKeyOpt_NoCRT(UINT8 *output,UINT32 *outputLen,UINT8 *input,UINT32 inputLen,R_RSA_PRIVATE_KEY *privateKey);  
	extern UINT8 ALGRsa_PR_Rsa_Init(void);
#endif
